//
//  FlyWebViewController.m
//  MedicalProject
//
//  Created by lifayu on 17/1/5.
//  Copyright © 2017年 贵阳飞云科技有限公司. All rights reserved.
//

#import "FlyWebViewController.h"

@interface FlyWebViewController ()


@end

@implementation FlyWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = _webTitle;
    self.view.backgroundColor = kWhiteColor;
    [self configNavigationLeftItemWithImage:nil];
    [self reloadRequest];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    self.navigationController.navigationBar.backgroundColor = kWhiteColor;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void) reloadRequest
{
    if([self.webUrl hasPrefix:@"http"]){
        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[self.webUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
        [_webView loadRequest:request];
    }else{
        [_webView loadHTMLString:self.webUrl baseURL:nil];
    }
    
    
    
}

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    [[HUDHelper sharedInstance] syncLoading];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [[HUDHelper sharedInstance] syncStopLoading];
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    [[HUDHelper sharedInstance] syncStopLoading];
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
